<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Popular_model extends CI_Model {
	
	var $request_params;

	function __construct() {
		parent::__construct();

	}
	
	/**
	 * 인기스타 리스트
	 */
	function select_popular_star_list($popular_id) {
		log_message('debug',"#### Popular_model::select_popular_star_list($popular_id)");

		$this->db->select('P.priority, A.idx, A.artist_name, A.job, A.birth_yyyy, A.birth_mm, A.birth_dd, A.sex, A.body, A.photo');
		$this->db->from('tb_popular_star P');
		$this->db->join('tb_artist A', 'P.artist_idx = A.idx');
		$this->db->where('P.popular_id', $popular_id);
		$this->db->where('P.use_yn', 'Y');
		$this->db->order_by('P.priority','ASC');
		$query = $this->db->get() or $this->logsql->log_sql('error');
		$result = $query->result_array();
		
		$this->logsql->log_sql();
		$this->logsql->log_result($result);
		
		return $result;
	}
	
	/**
	 * 인기스타 추가
	 */
	function insert_popular_star($popular_id, $artist_idx, $artist_name, $priority) {
		log_message('debug',"#### Popular_model::insert_popular_star($popular_id, $artist_idx, $artist_name, $priority)");

		$this->db->set('popular_id' , $popular_id);
		$this->db->set('artist_idx' , $artist_idx);
		$this->db->set('artist_name', $artist_name);
		$this->db->set('priority'   , $priority);
		$this->db->set('use_yn'    , 'Y');
		$this->db->insert('tb_popular_star') or $this->logsql->log_sql('error');

	}

	/**
	 * 인기스타 삭제
	 */
	function delete_popular_star($popular_id, $artist_idx) {
		log_message('debug',"#### Popular_model::delete_popular_star($popular_id, $artist_idx)");
		
		$this->db->where('popular_id',$popular_id);
		$this->db->where('artist_idx',$artist_idx);
		$this->db->delete('tb_popular_star') or $this->logsql->log_sql('error');
	}
	
}

/* End of file popular_model.php */
/* Location: ./application/models/unse/popular_model.php */